package com.switchcase;

import java.util.Scanner;

/**
 * @author: wuhao
 * @since: 2021/4/21 22:49
 */
public class SwitchTest2 {

    /**
     * 从键盘分别输入年、月、日，判断这一天是当年的第几天
     * 注：判断一年是否是闰年的标准：
     * 1）可以被4整除，但不可被100整除
     * 或
     * 2）可以被400整除
     */
    public static void main(String[] args) {

        System.out.println("请输入年:");
        int year = new Scanner(System.in).nextInt();
        System.out.println("请输入月:");
        int month = new Scanner(System.in).nextInt();
        System.out.println("请输入日:");
        int day = new Scanner(System.in).nextInt();
        //1 3 5 7 8 10 12
        //判断是否是闰年，闰年29天
        int february;
        //1)可以被400整除        2)可以被4整除，但不可被100整除
        if (year % 400 == 0 || (year % 4 ==0 && year % 100 !=0)){
            february = 29;
            System.out.println("提示："+year+"年是润年，2月有"+february+"天！");
        }else{
            february = 28;
        }
        int count = 0;
        switch (month) {
            case 12:
                count += 30;
            case 11:
                count += 31;
            case 10:
                count += 30;
            case 9:
                count += 31;
            case 8:
                count += 31;
            case 7:
                count += 30;
            case 6:
                count += 31;
            case 5:
                count += 30;
            case 4:
                count += 31;
            case 3:
                count += february;
            case 2:
                count += 31;
            case 1:
                count+=day;
        }
        System.out.println("当前日期为"+year+"年的第"+count+"天");
    }
}
